import { createBrowserRouter, Navigate } from 'react-router-dom';
import App from '../App';
import LoginPage from '../pages/LoginPage';
import DiaryPage from '../pages/DiaryPage';
import NotesPage from '../pages/NotesPage';
import PasswordManagerPage from '../pages/PasswordManagerPage';
import AIChatPage from '../pages/AIChatPage';
import ProtectedRoute from '../components/ProtectedRoute';

// 在导入部分添加RegisterPage
import RegisterPage from '../pages/RegisterPage';

// 在路由配置中添加注册路由
const router = createBrowserRouter([
  {
    path: '/',
    element: <App />,
    children: [
      {
        path: '', // 默认根路径
        element: <Navigate to="/login" replace />
      },
      {
        path: 'login',
        element: <LoginPage />
      },
      {
        path: 'register',  // 添加注册路由
        element: <RegisterPage />
      },
      {
        path: 'diary',
        element: <ProtectedRoute><DiaryPage /></ProtectedRoute>
      },
      {
        path: 'notes',
        element: <ProtectedRoute><NotesPage /></ProtectedRoute>
      },
      {
        path: 'passwords',
        element: <ProtectedRoute><PasswordManagerPage /></ProtectedRoute>
      },
      {
        path: 'ai-chat',
        element: <ProtectedRoute><AIChatPage /></ProtectedRoute>
      }
    ]
  }
]);

export default router; // 添加默认导出